package com.mapper;

import com.model.Cart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CartMapper {
    @Select("select * from cart")
    public List<Cart> getCartList();

    @Select("select * from cart where userid=#{id}")
    public List<Cart> getCartById(@Param("id") Long id);

    @Insert("insert into cart(userid,itemid,quantity) values(#{userid},#{itemid},#{quantity})")
    public boolean addCartItem(@Param("userid")Long userid,@Param("itemid")Long itemid,@Param("quantity")int quantity);

    @Delete("delete from cart where id=#{cartid}")
    public boolean deleteCartItem(@Param("cartid")Long CartId);
}
